package top.huiwow.commands;


import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import top.huiwow.GameCore;
import top.huiwow.items.AkaishiBaseItem;
import top.huiwow.utils.ItemBuilder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class GetItemCommand implements CommandExecutor{

    List<String> groupnames = new ArrayList<>();

    public GetItemCommand() {

    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = ((Player) sender);
            if (args.length == 1) {
                AkaishiBaseItem baseItem=GameCore.getInstance().getItemManager().getItem(args[0]);
                if (baseItem==null){
                    player.sendMessage("CANNOT FIND THE ITEM!");
                    return true;
                }

                ItemStack toGive = ItemBuilder.build(baseItem);
                player.getInventory().addItem(toGive);
                player.sendMessage("success");
            } else {
                sender.sendMessage("correct usage:/getitem <name>");
            }
        }

        return true;
    }



}
